#!/usr/bin/perl
+use warnings;
+
+use File::Basename;
+
#
# makedoc.in is used to generate makedoc. Editing makedoc is a bad idea.
#
-@options;
+my %options;
sub expandrw {
my $read = shift;
$olist = $options{$f};
# If no options, don't clutter things.
- if ( $olist eq "" ) { return; }
+ if ( not defined($olist) ) { return; }
# Comma separate the human-readable variation.
$olist =~ s/> </>, </g;
print PARTS qq(<!ENTITY inc_$name2 SYSTEM "../$dir2/$name.xml">\n);
print FILE "\&inc_$name2;\n";
if ( !-e "$dir/$dir2/$name.xml" ) {
- open TMP, ">$dir/$dir2/$name.xml";
- print TMP "\n";
- close TMP;
+ open $tmp, '>', "$dir/$dir2/$name.xml" or die $!;
+ print $tmp "\n";
+ close $tmp;
}
}
print FORMATS "\&inc_$name2;\n";
}
-$dir = $0;
-$dir =~ s:/.*$::;
+$dir = dirname($0);
-@agdir = `mkdir -p $dir/autogen`;
+qx(mkdir -p $dir/autogen);
+if ( $? != 0 ) {
+ die "error creating autogen directory: $?";
+}
open PARTS, ">$dir/autogen/_parts.xml";
print PARTS qq(<!-- This document is automatically generated. -->\n);
print PARTS qq(<!ENTITY formats SYSTEM "_formats.xml">\n);
open FORMATS, ">$dir/autogen/_formats.xml";
print FORMATS qq(<!-- This document is automatically generated. -->\n);
-@formats = `./gpsbabel -^3`;
+@formats = qx(./gpsbabel -^3);
+if ( $? != 0 ) {
+ die "error running gpsbabel: $?";
+}
$going = 0;
$dooptions = 0;
s/</\</g;
s/>/\>/g;
@line = split "\t";
+ next if ( scalar(@line) < 1 );
if ( ( $line[0] eq 'file' ) || ( $line[0] eq 'serial' ) ) {
$fmt = $line[2];
}
$skipping = 0;
}
- if ( $line[0] eq 'internal' || $line[5] eq 'xcsv' ) {
+ if ( ( $line[0] eq 'internal' )
+ || ( defined( $line[5] ) && ( $line[5] eq 'xcsv' ) ) )
+ {
$skipping = 1;
}
if ( $line[0] eq 'option' && $skipping == 0 ) {
s/</\</g;
s/>/\>/g;
@line = split "\t";
+ next if ( scalar(@line) < 1 );
if ( $line[0] eq 'internal' ) {
if ($going) {
open FORMATS, ">$dir/autogen/_filters.xml";
print FORMATS qq(<!-- This document is automatically generated. -->\n);
-@filters = `./gpsbabel -%1`;
+@filters = qx(./gpsbabel -%1);
+if ( $? != 0 ) {
+ die "error running gpsbabel: $?";
+}
$going = 0;